﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FHtool
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
            this.MaximizeBox = false;
            this.MinimizeBox = false;
        }

        private void txtName_Enter(object sender, EventArgs e)
        {
            //txtName.ForeColor = Color.White;
            //txtName.BackColor = Color.Blue;
        }

        private void txtName_Leave(object sender, EventArgs e)
        {
            //txtName.ForeColor = Color.White;
            //txtName.BackColor = Color.Black;
        }

        private void txtName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar >= 'a' && e.KeyChar <= 'z') || (e.KeyChar >= 'A' && e.KeyChar <= 'Z') || (e.KeyChar == (char)8))
            {
                e.Handled = false;
            }
            else
            {
                MessageBox.Show("用户名只能为字母！");
                e.Handled = true;
            }
        }

        private void txtPwd_Enter(object sender, EventArgs e)
        {
            //txtPwd.ForeColor = Color.White;
            //txtPwd.BackColor = Color.Blue;
        }

        private void txtPwd_Leave(object sender, EventArgs e)
        {
            //txtName.ForeColor = Color.White;
            //txtName.BackColor = Color.Black;
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            string userName = txtName.Text;
            string password = txtPwd.Text;

            if (userName == "admin" && password == "admin")
            {
                //MessageBox.Show("登录成功！", "提示！");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("您输入的用户名或密码错误！", "登录失败！", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        #region 清除输入信息，并将光标定位在txtName文本框中
        private void btnCancel_Click(object sender, EventArgs e)
        {
            txtName.Text = "";
            txtPwd.Text = "";
            txtName.Focus();
        }
        #endregion

        
    }
}
